<?php
class DataUserGames{
	private $GamesList = array();
	function __construct(){
	}
	static function swap($bytebuffer){
		$obj = new DataUserGames();
		$num_of_games = DataUtil::readInt32( $bytebuffer ) ;
		for($i = 0; $i < $num_of_games; $i++){
			$obj->GamesList[] = DataUtil::readInt32( $bytebuffer ) ;
		}
		return $obj;
	}
	function getGames(){
		return $this->GamesList;
	}
	function addGame($gameid){
		$this->GamesList[] = $gameid;
	}
	function getBinSize(){
		$size = 0; 
		$size += 4 ;
		if(is_array($this->GamesList)){
			foreach($this->GamesList as $gameid){
				$size += 4 ;
			}
		}
		return $size;
	}
	function getBinary(){
		$buf = ByteBuffer::allocate( $this->getBinSize() ) ;
		DataUtil::writeInt32( $buf , count($this->GamesList) ) ;
		if(is_array($this->GamesList)){
			foreach($this->GamesList as $gameid){
				DataUtil::writeInt32( $buf , $gameid ) ;
			}
		}
		return  $buf ->_array() ;
	}
}
?>